package controllers;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

import modelo.Propietario;
import modelo.Salon;
import modelo.Servicioadicionalxsalon;
import modelo.Tiposuscripcion;
import modelo.Usuario;
import services.PropietarioService;
import services.SalonService;
import services.ServicioAdicionalXSalonService;
import services.TipoSuscripcionService;


@ManagedBean
@ViewScoped
public class ConsultarSalonBean implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -7267319135561739444L;

	@ManagedProperty("#{salonService}")
	private SalonService serviceSalon=new SalonService();
	private Salon salon=new Salon();

	@ManagedProperty("#{servicioAdicionalxSalonService}")
	private ServicioAdicionalXSalonService serviceServicioAdicionalxSalon;
	List<Servicioadicionalxsalon> listaServicioAdicionalxSalon = new ArrayList<Servicioadicionalxsalon>();
	private Servicioadicionalxsalon servicioadicionalxsalonSelected=new Servicioadicionalxsalon();		
	
	private List<Salon> listaSalonProp;
	private Salon salonSelected;

	public ConsultarSalonBean() {
		super();
		listaSalonProp=new ArrayList<Salon>();
		salonSelected=new Salon();
	}

	@PostConstruct
	private void init() {
		//serviceSalon.init();
		listaSalonProp=serviceSalon.getListaSalonProp();
		//listaServicioAdicionalxSalon=serviceServicioAdicionalxSalon.getListaservicioadicionalxsalon();		
	}

	public SalonService getServiceSalon() {
		return serviceSalon;
	}

	public void setServiceSalon(SalonService serviceSalon) {
		this.serviceSalon = serviceSalon;
	}

	public Salon getSalon() {
		return salon;
	}

	public void setSalon(Salon salon) {
		this.salon = salon;
	}

	public List<Salon> getListaSalonProp() {
		return listaSalonProp;
	}

	public void setListaSalonProp(List<Salon> listaSalonProp) {
		this.listaSalonProp = listaSalonProp;
	}

	public Salon getSalonSelected() {
		return salonSelected;
	}

	public void setSalonSelected(Salon salonSelected) {
		this.salonSelected = salonSelected;
	}
	
	
	public void llenarTablaServicios(){
		listaServicioAdicionalxSalon = serviceServicioAdicionalxSalon.obtenerServicioAdicionalXSalon(salonSelected.getIdSalon());
	}

	public ServicioAdicionalXSalonService getServiceServicioAdicionalxSalon() {
		return serviceServicioAdicionalxSalon;
	}

	public void setServiceServicioAdicionalxSalon(
			ServicioAdicionalXSalonService serviceServicioAdicionalxSalon) {
		this.serviceServicioAdicionalxSalon = serviceServicioAdicionalxSalon;
	}

	public List<Servicioadicionalxsalon> getListaServicioAdicionalxSalon() {
		return listaServicioAdicionalxSalon;
	}

	public void setListaServicioAdicionalxSalon(
			List<Servicioadicionalxsalon> listaServicioAdicionalxSalon) {
		this.listaServicioAdicionalxSalon = listaServicioAdicionalxSalon;
	}

	public Servicioadicionalxsalon getServicioadicionalxsalonSelected() {
		return servicioadicionalxsalonSelected;
	}

	public void setServicioadicionalxsalonSelected(
			Servicioadicionalxsalon servicioadicionalxsalonSelected) {
		this.servicioadicionalxsalonSelected = servicioadicionalxsalonSelected;
	}	
	
	public String goMenu()
	{
	        FacesContext context1 = FacesContext.getCurrentInstance();
	    	HttpSession session;
		    session = (HttpSession) context1.getExternalContext().getSession(true);
		    session.setAttribute("salon",salonSelected.getIdSalon());	
		
		return "Menu";
	}
	
	public String goBebida()
	{
	        FacesContext context1 = FacesContext.getCurrentInstance();
	    	HttpSession session;
		    session = (HttpSession) context1.getExternalContext().getSession(true);
		    session.setAttribute("salon",salonSelected.getIdSalon());	
		
		return "Bebida";
	}	
	
	public String goServicios()	
	  {
        FacesContext context1 = FacesContext.getCurrentInstance();
    	HttpSession session;
	    session = (HttpSession) context1.getExternalContext().getSession(true);
	    session.setAttribute("salon",salonSelected.getIdSalon());	
	
	    return "Servicios";
       }	
	
	public String goPresupuesto()
	{
	        FacesContext context1 = FacesContext.getCurrentInstance();
	    	HttpSession session;
		    session = (HttpSession) context1.getExternalContext().getSession(true);
		    session.setAttribute("salon",salonSelected.getIdSalon());	
		
		return "Presupuesto";
	}	
	}
